Data Types
Numeric
| Data Type | Description |
|---|---|
TINYINT | Small integer, range: -128 to 127 or 0 to 255 (unsigned). |
SMALLINT | Larger range than TINYINT, range: -32,768 to 32,767. |
MEDIUMINT | Medium integer, range: -8,388,608 to 8,388,607. |
INT or INTEGER | Standard integer, range: -2,147,483,648 to 2,147,483,647. |
BIGINT | Large integer, range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. |
DECIMAL | Fixed-point numbers with exact precision, e.g., salaries or monetary values. |
FLOAT | Floating-point numbers (approximate precision). |
DOUBLE | Larger floating-point numbers than FLOAT (also approximate). |
BIT | Used for storing bit values, e.g., binary data like 1010. |
In Terms of Capacity
TINYINT < SMALLINT < MEDIUMINT < INT < BIGINT
In Terms of Precision Handling
FLOAT < DOUBLE < DECIMAL
String
| Data Type | Description |
|---|---|
CHAR | Fixed-length string, up to 255 characters. |
VARCHAR | Variable-length string, up to 65,535 characters (depending on row size). |
TINYTEXT | Short text, up to 255 characters. |
MEDIUMTEXT | Medium-length text, up to 16,777,215 characters. |
TEXT | Long text data, used for large strings (e.g., articles or comments). |
LONGTEXT | Very long text, up to 4,294,967,295 characters. |
BLOB | Binary Large Object, used for binary data like images or files. |
ENUM | String object with predefined values, e.g., 'small', 'medium', 'large'. |
SET | String object storing multiple predefined values (comma-separated). |
In Short
CHAR → VARCHAR → TINYTEXT → TEXT → MEDIUMTEXT → LONGTEXT
Date and Time
| Data Type | Description |
|---|---|
YEAR | Stores the year in 4-digit format, e.g., 2024. |
TIME | Stores time in HH:MM:SS format. |
DATE | Stores date in YYYY-MM-DD format. |
DATETIME | Stores both date and time in YYYY-MM-DD HH:MM:SS format. |
TIMESTAMP | Similar to DATETIME, but it automatically updates with the current date/time when modified. |